﻿from utilities import *
from google.appengine.api import users  
from utilities import *
from entities import * 
   
def Header(self,page):
    head = '<div id="header">'
    head += '<div class="top">'
    head += '<div style="float: left;">'
    head += '<a href=""><span class="logo" style="display: inline-block;"></span></a>'
    head += '</div>'
    head += '<div class="links">'
    head += '<p>Welcome to the BKStore Portal</p>'
    head +=  Utils.signin(self)
    head += '</div>'
    head += '<div class="clear"></div>'
    head += '</div>'
  
    head += '<div class="border">'
    head += '<div id='+page+'>'
    head += '<div id="top-nav">'
    head += Menu()
    head += '</div>'
    head += '</div>'
    head += '<div class="clear"></div>'
    head += '</div>'
    head += '</div>'
    return head
    
def Footer():
    foot = '<div id="footer">'
    foot += '<div class="border">'
    foot += '<div class="links">'
    foot += '<ul>'
    foot += '<li><a href="">Welcome</a></li>'
    foot += '<li><a href="">FAQs</a></li>'
    foot += '<li><a href="">Contact Us</a></li>'
    foot += '<li><a href="">Feedback</a></li>'
    foot += '<li><a href="">Blog</a></li>'
    foot += '</ul>'
    foot += '</div>'
    foot += '<div class="copyright">© 2011 AndroidStore</div>'
    foot += '</div>'
    foot += '</div>'
    return foot

def CSS():
    css = '<link type="text/css" rel="stylesheet" href="static/page.css" />'
    css += '<link type="text/css" rel="stylesheet" href="static/global.css" />'
    css += '<link type="text/css" rel="stylesheet" href="static/tabs.css" />'
    css += '<link type="text/css" rel="stylesheet" href="static/dp-content.css" />'
    return css
    
    
def Menu():
    user = users.get_current_user()
    menu = ''
    menu += '<div id="home_link"><a href="/">Home</a></div>' 
    if(user):
        if user == users.User("ngothuha.aoc@gmail.com"):
            menu += '<div id="addSource_link"><a href="/Admin">Add Source</a></div>'
        else:
            userID = User.GetID(user)
            if userID > 0:
                us = Entities.User.get_by_id(userID)
                RoleName = us.RoleID.RoleName
     
                if RoleName == "Developer":
                    menu += '<div id="addApp_link"><a href="/AddAppForm">Add New App</a></div>'
                    menu += '<div id="myapps_link"><a href="/MyApp">My Apps</a></div>'
                    menu += '<div id="reports_link"><a href="">Reports</a></div>'
                    menu += '<div id="settings_link"><a href="">My Account</a></div>'
                elif RoleName == "Customer":
                    menu +=''
            else:
                menu += '<div id="registerUser_link"><a href="/RegisterUser">Register</a></div>' 
    return menu